@ts-nocheck
<template>
  <div class="card-container">
    <el-card
      class="card-wrap"
      v-for="(card, indexCardData) in cardData"
      :key="'card_' + indexCardData"
      shadow="hover"
      :body-style="{ padding: '6px 6px 6px 12px' }"
    >
      <div class="card-content">
        <h1 style="padding: 0 0.5em 0 0">{{ card.sector }}</h1>
        <div class="content-holder">
          <div v-for="content in card.content" class="content-holder-content">
            <div class="content-holder-level">
              <span v-for="levelValue in content.levels">
                <el-tooltip
                  v-if="content.remarks.length > 0"
                  effect="dark"
                  :content="content.remarks.join('; ')"
                  placement="right"
                >
                  <el-button
                    round
                    plain
                    type="warning"
                    size="small"
                    style="padding: 4px 8px; margin: 2px"
                  >
                    {{ levelValue }}
                  </el-button>
                </el-tooltip>
                <el-button
                  v-else
                  round
                  plain
                  type="primary"
                  size="small"
                  style="padding: 4px 8px; margin: 2px"
                >
                  {{ levelValue }}
                </el-button>
              </span>
              <span
                v-for="(
                  restrictedRemark, restrictedRemarkIndex
                ) in content.restrictedLevels"
                :key="'restrictedRemark_' + restrictedRemarkIndex"
              >
                <el-tooltip
                  v-for="restrictedLevels in restrictedRemark.levels"
                  effect="dark"
                  :content="
                    restrictedRemark.remark +
                    (card.remarks && card.remarks.length
                      ? ';' + card.remarks.join('; ')
                      : '')
                  "
                  placement="right"
                >
                  <el-button
                    round
                    plain
                    type="danger"
                    size="small"
                    style="padding: 4px 8px; margin: 2px"
                  >
                    {{ restrictedLevels }}</el-button
                  >
                </el-tooltip>
              </span>
            </div>
            <div class="content-holder-detail">
              <div
                v-for="detail in content.details"
                class="content-holder-detail-route"
              >
                <el-icon
                  color="#e6a23c"
                  v-if="selectedSectors.indexOf(detail.handin) > -1"
                >
                  <CaretRight />
                </el-icon>
                <el-icon
                  color="#67c23a"
                  v-if="selectedSectors.indexOf(detail.handout) > -1"
                >
                  <CaretLeft />
                </el-icon>
                <el-tooltip
                  class="item"
                  effect="dark"
                  :content="'机场: ' + detail.airports.join(' , ')"
                  placement="right"
                >
                  <el-button size="small" text class="button-route">{{
                    detail.route
                  }}</el-button>
                  <!-- <el-tag type="info" size="small" effect="plain" class="tag-route"> {{ detail.airports.join(' , ') }}
                </el-tag> -->
                </el-tooltip>
              </div>
            </div>
          </div>
        </div>
      </div>
    </el-card>
    <!-- <div class="copper-content" v-show="popperVisible">{{ popperContent }}</div> -->
  </div>
</template>

<script>
import { mapWritableState } from "pinia";
import useTransferStore from "@/store/transfer";
import useCommonStore from "@/store/common";
export default {
  setup() {
    const transferStore = useTransferStore();
    const commonStore = useCommonStore();
    return {
      commonStore,
      transferStore,
    };
  },
  data() {
    return {
      showContent: true,
      popperContent: "",
      popperVisible: false,
      popperPosition: [0, 0],
    };
  },
  computed: {
    ...mapWritableState(useTransferStore, {
      filter: "filter",
      card: "card",
    }),
    selectedSectors() {
      return this.filter.selectedSectors;
    },
    cardData() {
      return this.card;
    },
  },
};
</script>

<style scoped>
@media screen and (min-width: 1200px) {
  .card-container {
    width: calc(100% - 5px);
    margin: 0;
    columns: 3;
    column-gap: 30px;
  }
}

@media screen and (min-width: 768px) and (max-width: 1199.98px) {
  .card-container {
    width: calc(100% - 5px);
    margin: 0;
    columns: 2;
    column-gap: 30px;
  }
}

@media screen and (max-width: 767.98px) {
  .card-container {
    width: calc(100% - 5px);
    margin: 0;
    columns: 1;
    column-gap: 30px;
  }
}

.content-holder {
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: left;
  align-items: center;
}

.content-holder > last-child {
  border: none;
}

.content-holder-content {
  width: 100%;
  display: flex;
  justify-content: left;
  align-items: center;
  padding: 6px 12px;
  border-bottom: 1px solid rgba(128, 128, 128, 0.3);
}

.content-holder-level {
  width: 60px;
  display: flex;
  flex-direction: column;
  justify-content: left;
  align-items: center;
  /* padding: 0 12px; */
}

.content-holder-detail {
  padding: 0;
  margin: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: left;
  align-items: center;
  /* border: 1px solid #fff; */
  /* padding: 0 12px; */
}

.content-holder-detail-route {
  width: 100%;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  padding-left: 12px;
  margin: 0;
}

.card-wrap {
  width: 100%;
  break-inside: avoid;
  margin-bottom: 30px;
  padding: 0;
  border: 1px solid rgba(128, 128, 128, 0.3);
  border-radius: 6px;
  padding: 12px 18px;
  transition: all 0.3s ease-in-out;
  /* font-family: "consolas"; */
}

.card-wrap:hover {
  box-shadow: 0px 2px 15px rgba(0, 0, 0, 0.2);
}

.button-route {
  padding: 0px 6px;
  margin: 0;
}

.tag-route {
  padding: 0px 3px;
  margin: 0;
}

.card-content {
  display: flex;
  justify-content: left;
  align-items: center;
}

.content-levels {
  display: inline;
  align-items: center;
}

.el-table .warning-row {
  background: oldlace;
}

.el-table .success-row {
  background: #f0f9eb;
}
</style>

<style>
.el-table::before {
  height: 0px;
}

.el-table--enable-row-hover .el-table__body tr:hover > td {
  background-color: transparent;
}
</style>
